Allow messenger handler to return non-resource output#2878
Conversation
|
I've already explained to you on Slack why this is wrong. But let me say it again: it's the job of the DataTransformer to transform a resource to the output DTO. If you want to return a non-resource, just remove the |
|
Sorry for bothering you again with this case but I'm not seeing an alternative in the approach you suggest. Moreover, it was working in 2.4.2. Why a bugfix update breaks the backwards compatibility?
the output model is auto-documented. If I remove the output, the documentation will be missing.
the code would be too scattered if ResetPasswordRequestHandler returned a resource and ResetPasswordRequestDataTransformer returned an output object. Also, the resource doesn't have to be convertable to the output dto. My points are:
I'm wondering what is @dunglas and @soyuka opinion on this case. |
Wait we'ŕe in the context of a MessageHandler, isn't it a bit different? Could the MessageHandler act as a data transformer? Shouldn't we support non-resources anyway (to me we definitely should)?
To me this makes sense and removes some useless boilerplate code. I don't really see anything wrong with the PR here, it just simplifies this use case no? |
|
Hey guys! What should I do to get this PR merged? Submit it again? Add some
tests?
…On Wed, Jun 26, 2019, 3:14 PM Antoine Bluchet ***@***.***> wrote:
I've already explained to you on Slack why this is wrong. But let me say
it again: it's the job of the DataTransformer to transform a resource to
the output DTO. If you want to return a non-resource, just remove the
output option and it should work.
Wait we'ŕe in the context of a MessageHandler, isn't it a bit different?
Could the MessageHandler act as a data transformer? Shouldn't we support
non-resources anyway (to me we definitely should)?
the code would be too scattered if ResetPasswordRequestHandler returned a
resource and ResetPasswordRequestDataTransformer returned an output object.
To me this makes sense and removes some useless boilerplate code.
I don't really see anything wrong with the PR here, it just simplifies
this use case no?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2878?email_source=notifications&email_token=AAMY6GLPMIWPBGGKZRIEIFDP4NMTLA5CNFSM4H3LURP2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODYTKJDY#issuecomment-505848975>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAMY6GO6OOTYJYBQMPL2FADP4NMTLANCNFSM4H3LURPQ>
.
|
This is the actual issue, a more general problem. We should allow documenting any classes. Otherwise it's already correct. Just don't use |
|
@teohhanhui You are right, the documentation - that's what I use the output for.
How do you imagine that? A special option or using swagger_context? Tweaking |
|
Let's continue that discussion in #2147 |

Hi folks!
Let's imagine ResetPasswordRequest / ResetPasswordRequestHandler case from the api-platform docs (https://api-platform.com/docs/core/messenger/).
Before api-platform v2.4.3 it was possible to return the output dto object (ResetPasswordResponse) directly from the messenger handler. It was very convenient, and that's what dto's are for - return a custom response without exposing an entity.
As of v2.4.3 it started to complain that ResetPasswordResponse must be a resource, so this PR allows returning the non-resource output.